home *** CD-ROM | disk | FTP | other *** search
MarxMenu script | 1996-07-10 | 12.4 KB | 408 lines |
- Comment
- ========================================================================
-
- Novell menu to MarxMenu Translator:
-
- Copyright 1989-91 by Marc Perkel * All rights reserved.
-
- Usage: MARXMENU NOVTRANS <novell menu>
-
- This program was written to translate Novell menus to MarxMenus. It is
- not an exact translation, but does the bulk of the work. It is up to you
- to edit the output file and tune the menu the way you want.
-
- I have made no attempt to copy color information. I am not presenting
- selections in sorted order, but in the order in which they are defined.
-
- The program creates a MarxMenu file names <menu>.TMP where <menu> is the
- name of your Novell menu file. Then it compiles <menu>.TMP into
- <menu>.MRX file that should be ready to run. if the menu needs to be
- altered, you will have to rename the <menu>.TMP file to a MNU file and
- then you can work with it like any other MarxMenu source file.
-
- ========================================================================
- EndComment
-
- Var
- NovLines Menus Tmp MenuPtr ChoicePtr CommandPtr LinePtr
- BoxDim X Y Z VarNum PromptLine Out Cap InputAVar NovellFileName
- MarxMenuFileName NovellTempFileName Greek
-
- ;----- Translator Messages
-
- Const
- TopMessage = "Joe Blow's Master Menu"
- BottomMessage = "*-<< Acme Manufacturing Company >>-*"
-
- ;----- If you want the Greek Column effect, set to true
-
- Greek = False
-
- Qualifier MenuName YPos XPos MenuColor MenuChoices
- Qualifier ChoiceName ChoiceCmd
-
- Comment
- ========================================================================
-
- This is the main body of the NovTrans Program.
-
- ========================================================================
- EndComment
-
- if not NetWorkVersion
- ClearScreen
- Writeln
- Writeln 'This translator requires the network version of MarxMenu to Run!'
- endif
-
- PreAmble
- PrepareFiles
- Header
- Parse
- WriteOutMenus
- Footer
-
- ClearScreenFirst Off
- Writeln
- Execute 'MARXCOMP.EXE ' + MarxMenuFileName
-
- Writeln
- Writeln 'To test your menu type MARX ' NovellFileName '. When you are satisfied with'
- Writeln 'the translation, replace the Novell ' NovellFileName '.MNU file'
- Writeln 'with the ' MarxMenuFileName ' file that NovTrans just created.'
-
- Comment
- =====================================
-
- Subroutine area.
-
- =====================================
- EndComment
-
- ;----- Initilize Variables and Environment
-
- Procedure PreAmble
- ClearScreenOnExit Off
- StandardIO
- Writeln
- NovellFileName = UpperCase(ParamStr(2))
- Usage
- EndProc
-
- ;----- Proper Usage Procedure
-
- Procedure Usage
- if NovellFileName = ''
- Writeln('Usage: MarxMenu NovTrans <menu>')
- Writeln('Converts Novell menus to MarxMenus.')
- Writeln('Be sure to backup your original menus before running!!')
- ExitMenu
- endif
- EndProc
-
- ;----- Create FileNames and open Files
-
- Procedure PrepareFiles
- if pos('.',NovellFileName) > 0
- NovellFileName = left(NovellFileName,pred(pos('.',NovellFileName)))
- endif
-
- NovellTempFileName = NovellFileName + '.MNU'
- MarxMenuFileName = ForceExtension(NovellTempFileName,'TMP')
-
- ReadTextFile NovellTempFileName NovLines
- Writeln 'Creating ' MarxMenuFileName
-
- FileAssign(Out,MarxMenuFileName)
- FileCreate(Out)
- EndProc
-
-
- Procedure BlankLine
- FileWriteln(Out,'')
- EndProc
-
- ;----- Write out the MarxMenu Source Header
-
- Procedure Header
- BlankLine
- FileWriteln(Out,'Comment')
- FileWriteln(Out,'==========================================================')
- BlankLine
- FileWriteln(Out,'This File was converted from Novell Menu: ',NovellTempFileName)
- BlankLine
- FileWriteln(Out,'It should behave in a similar way to the original menu but')
- FileWriteln(Out,'not necessarilly exactly the same. It will be close enough')
- FileWriteln(Out,'for you to fine tune it the way you want.')
- BlankLine
- FileWriteln(Out,'To add a choice to a menu simply use the AddChoice command')
- FileWriteln(Out,'then add the appropiate Onkey statement.')
- FileWriteln(Out,'The menu will make the size adjustments accordinaly.')
- BlankLine
- FileWriteln(Out,' Example:')
- FileWriteln(Out,' AddChoice("Print Console",10)')
- FileWriteln(Out,' ... ')
- FileWriteln(Out,' ... ')
- FileWriteln(Out,' OnKey Task(10)')
- FileWriteln(Out,' PConsole')
- FileWriteln(Out,' ...')
- BlankLine
- FileWriteln(Out,"If you want to change the menu's center, pass the XY")
- FileWriteln(Out,"coordinates to menu's CenterStretchBox procedure.")
- BlankLine
- FileWriteln(Out,' Example:')
- FileWriteln(Out,' CenterStretchBox("Menu Header",10,10)')
- BlankLine
- FileWriteln(Out,'This will cause the menu to center at Col 10, Row 10')
- BlankLine
- FileWriteln(Out,'Once you are satisfied with the translation you can copy the TMP file')
- FileWriteln(Out,'over the old Novell MNU file and just work with the MarxMenu version.')
- BlankLine
- FileWriteln(Out,'To control custom features, edit CUSTOM.INC and other INCLUDE Files.')
- BlankLine
- FileWriteln(Out,'=========================================================')
- FileWriteln(Out,'EndComment')
- BlankLine
- FileWriteln(Out,';----- Create Variables')
- BlankLine
- FileWriteln(Out,'var')
- FileWriteln(Out,' %NovVar1')
- FileWriteln(Out,' %NovVar2')
- FileWriteln(Out,' %NovVar3')
- FileWriteln(Out,' %NovVar4')
- FileWriteln(Out,' %NovVar5')
- FileWriteln(Out,' %NovVar6')
- FileWriteln(Out,' %NovVar7')
- FileWriteln(Out,' %NovVar8')
- FileWriteln(Out,' %NovVar9')
- FileWriteln(Out,' %NovVar10')
- FileWriteln(Out,' KeepUsersInMenu')
- BlankLine
- BlankLine
- FileWriteln(Out,';----- Here is where you add you own menu title and status line message')
- BlankLine
- FileWriteln(Out,'MenuTitle = "',TopMessage,'"')
- FileWriteln(Out,'StatusLineText = "',BottomMessage,'"')
- BlankLine
- FileWriteln(Out,';----- Load Novell look and feel routines')
- BlankLine
- FileWriteln(Out,'Include "CUSTOM.INC"')
- if Greek then FileWriteln(Out,'Greek = True')
- BlankLine
- FileWriteln(Out,'KeepUsersInMenu Off')
- BlankLine
- FileWriteln(Out,'Comment')
- FileWriteln(Out,'=================================')
- BlankLine
- FileWriteln(Out,'In order to add menu choices conditionally you would append the')
- FileWriteln(Out,'choices to the end of the array after all the default choices')
- FileWriteln(Out,'are set. For Example:')
- BlankLine
- FileWriteln(Out,' if NovInGroup("ACCOUNTING")')
- FileWriteln(Out,' AddChoice("Payroll Menu",10)')
- FileWriteln(Out,' endif')
- BlankLine
- FileWriteln(Out,'Here is where menus are created.')
- BlankLine
- FileWriteln(Out,'=================================')
- FileWriteln(Out,'EndComment')
- BlankLine
- FileFlush(Out);
- EndProc
-
-
- ;----- Write out the MarxMenu Source Footer
-
- Procedure Footer
- BlankLine
- FileWriteln(Out,';----- End of Menu')
- FileClose(Out)
- EndProc
-
-
- ;----- Delete all spaces in a string to make them a valid MarxMenu label
- ; Returns a string
-
- Procedure DeleteSpaces(St)
- while Pos(' ',St) > 0
- Delete(St,Pos(' ',St),1)
- endwhile
- while Pos('-',St) > 0
- Delete(St,Pos('-',St),1)
- endwhile
- while Pos('.',St) > 0
- Delete(St,Pos('.',St),1)
- endwhile
- while Pos('/',St) > 0
- Delete(St,Pos('/',St),1)
- endwhile
- if (Mid(St,2,1) >= '0') and (Mid(St,2,1) <= '9')
- Insert('X',St,2)
- endif
- Return St
- EndProc
-
- ;----- Parse Novell Source into MenuName, MenuChoices, MenuCommands
- ;----- Returns a integer pointing to the end of the menu prompt
-
- Procedure FindEndOfMenuPrompt(St)
- Var CommaPos Tail
-
- CommaPos = Pos(',',St)
- if CommaPos = 0 Then Return Length(St) + 1
- Tail = Mid(St,CommaPos + 1,255)
- loop(Length(Tail))
- if Pos(Mid(Tail,LoopIndex,1), '0123456789,') = 0
- Writeln
- Writeln('Error : There must not be any embedded commas in menu title!')
- Writeln(St)
- Writeln
- ExitMenu
- endif
- endloop
- Return CommaPos
- EndProc
-
- ;----- Preprocess Lines
-
- Procedure Parse
- Var TotalLines
- TotalLines = NumberOfElements(NovLines)
- Writeln('Parsing Novell Menu source code ...')
- MenuPtr = 0
- loop(TotalLines)
- if (LoopIndex Mod 10 = 0) or (LoopIndex = TotalLines)
- Write Cr
- Write('Processing Line # ',LoopIndex,' of ',TotalLines)
- endif
- if left(NovLines[LoopIndex],1) = '%'
- ChoicePtr = 0
- CommandPtr = 0
- MenuPtr = MenuPtr + 1
- Tmp = mid(NovLines[LoopIndex],2,255)
- X = FindEndOfMenuPrompt(Tmp)
- Menus[MenuPtr].MenuName = ':' + left(Tmp,X - 1)
- Tmp = mid(Tmp,X + 1,255)
- Menus[MenuPtr].YPos = value(NextWord(Tmp))
- Menus[MenuPtr].XPos = value(NextWord(Tmp))
- Menus[MenuPtr].MenuColor = value(NextWord(Tmp))
- else
- if left(NovLines[LoopIndex],1) > ' '
- CommandPtr = 0
- ChoicePtr = ChoicePtr + 1
- Trim(NovLines[LoopIndex])
- if Mid(NovLines[LoopIndex], 2, 1) = '.'
- Delete(NovLines[LoopIndex],1,2)
- Trim(NovLines[LoopIndex])
- endif
- Menus[MenuPtr].MenuChoices[ChoicePtr].ChoiceName = NovLines[LoopIndex]
- else
- if ChoicePtr = 0
- Writeln
- Writeln 'Error in menu line: ' LoopIndex
- ExitMenu
- endif
- CommandPtr = CommandPtr + 1
- Menus[MenuPtr].MenuChoices[ChoicePtr].ChoiceCmd[CommandPtr] = NovLines[LoopIndex]
- endif
- endif
- endloop
- EndProc
-
- ;----- Create the Menu Choices Array
-
- Procedure WriteOutMenuChoices
- Writeln
- Write('Translating: ' + mid(Menus[MenuPtr].MenuName,2,255) + ' ... ')
- BlankLine
- FileWriteln(Out,';----- Translating: ' + mid(Menus[MenuPtr].MenuName,2,255))
- BlankLine
- if MenuPtr > 1
- Tmp = Menus[MenuPtr].MenuName
- Tmp = DeleteSpaces(Tmp)
- FileWriteln(Out,Tmp)
- BlankLine
- endif
- loop(NumberOfElements(Menus[MenuPtr].MenuChoices))
- FileWriteln(Out,' AddChoice("' + Menus[MenuPtr].MenuChoices[LoopIndex].ChoiceName + '",' + Str(LoopIndex) + ')')
- endloop
- BlankLine
- FileWriteln(Out,'CenterStretchBox("' + Mid(Menus[MenuPtr].MenuName,2,255) + '",' + Str(Menus[MenuPtr].XPos) + ',' + Str(Menus[MenuPtr].YPos) + ')')
- BlankLine
- EndProc
-
- ;----- Create the Onkey Statements
-
- Procedure WriteOutOnkeyChoices
- loop(NumberOfElements(Menus[MenuPtr].MenuChoices))
- ChoicePtr = LoopIndex
- Tmp = Menus[MenuPtr].MenuChoices[ChoicePtr].ChoiceName
- FileWriteln(Out,'OnKey Task(' + Str(ChoicePtr) + ')')
- loop(NumberOfElements(Menus[MenuPtr].MenuChoices[ChoicePtr].ChoiceCmd))
- CommandPtr = LoopIndex
- Tmp = Menus[MenuPtr].MenuChoices[ChoicePtr].ChoiceCmd[CommandPtr]
- Trim(Tmp)
- if UpperCase(Tmp) = '!LOGOUT' then Tmp = '|Logoff'
- if Left(Tmp,1) = '%'
- Tmp = DeleteSpaces(Tmp)
- Tmp = '^' + Mid(Tmp,2,255)
- endif
- if (pos('@',Tmp) > 0) And (Pos('@ECHO',UpperCase(Tmp)) = 0)
- X = 1
- while X <= length(Tmp)
- while (X <= length(Tmp)) and (mid(Tmp,X,1) <> '@')
- X = X + 1
- endwhile
- Z[1] = mid(Tmp,X,1)
- Z[2] = mid(Tmp,X + 1,1)
- if (Z[1] = '@') and (((Z[2] > '0') and (Z[3] <= '9')) or (Z[2] = '"'))
- if Z[2] = '"'
- insert(' ',Tmp,X + 1)
- VarNum = 10
- else
- VarNum = ord(Z[2]) - 48
- endif
- InputAVar = mid(Tmp,X + 2,1) = '"'
- if InputAVar
- Y = X + 3
- while (mid(Tmp,Y,1) <> '"') and (Y <= length(Tmp))
- Y = Y + 1
- endwhile
- PromptLine = mid(Tmp,X + 3,Y - (X + 3))
- else
- Y = X + 1
- endif
- delete(Tmp,X,Y - X + 1)
- insert('%NovVar' + Str(VarNum) ,Tmp,X)
- if InputAVar
- FileWriteln(Out,' |%NovVar',Str(VarNum), ' = ReadTextLine("' + PromptLine + '","",0,21)')
- endif
- endif
- endwhile
- endif
- FileWriteln(Out,' ' + Tmp)
- endloop
- BlankLine
- endloop
- EndProc
-
- ;----- Create the Menus
-
- Procedure WriteOutMenus
- Var LoopCount
- Writeln
- LoopCount = MenuPtr
- Loop LoopCount
- MenuPtr = LoopIndex
- WriteOutMenuChoices
- WriteOutOnkeyChoices
- if MenuPtr = 1
- FileWriteln(Out,'OnKey ESC')
- FileWriteln(Out,' |if not KeepUsersInMenu or NovConsoleOperator')
- FileWriteln(Out,' | LeaveMenu')
- FileWriteln(Out,' |endif')
- BlankLine
- endif
- EndLoop
- EndProc